package com.itheima.vmmysql.Controller;

import com.itheima.vmmysql.Service.DataBasesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Controller
public class DataBaseController {
    @Autowired

    private DataBasesService dataBasesService;
    @GetMapping("/databases")
   public String getDataBase(@RequestParam("name")String dbName,Model model){
List<String> databaseList=dataBasesService.databaseList();
       model.addAttribute("databaseList",databaseList);
       model.addAttribute("dbName",dbName);
       return "html/databases";
   }
    public String getDataBase(Model model){
        List<String> databaseList=dataBasesService.databaseList();
        model.addAttribute("databaseList",databaseList);
        return "html/databases";
    }
}
